package com.djk.daily.kafka.wechat.common;

import lombok.Data;

import java.util.UUID;

/**
 * @Description 返回结果封装
 * @Author dujunkai
 * @Date 2021/12/3 9:31 下午
 **/
@Data
public class BaseResponseVO<M> {
    private String requestId;
    private M result;

    public static<M> BaseResponseVO success(){
        BaseResponseVO baseResponseVO = new BaseResponseVO();
        baseResponseVO.setRequestId(genRequestId());

        return baseResponseVO;
    }

    public static<M> BaseResponseVO success(M result){
        BaseResponseVO baseResponseVO = new BaseResponseVO();
        baseResponseVO.setRequestId(genRequestId());
        baseResponseVO.setResult(result);

        return baseResponseVO;
    }

    private static String genRequestId(){
        return UUID.randomUUID().toString();
    }
}
